<%@ page language="java" errorPage="/WEB-INF/common/exception.jsp" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ include file="/WEB-INF/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>文章管理</title>
<script type="text/javascript" language="javascript" src="<c:url value='/js/category/category.js' />" charset=utf-8></script>
<script type="text/javascript" language="javascript" src="<c:url value='/js/ckeditor/ckeditor.js' />" charset=utf-8></script>
<script type="text/javascript">
/**
 * 所属系统分类选择
 */
function openSelectSingleCategory() {
	var pid = $("input[type='hidden'][name='vo.category.id']").val();
	var url="/admin/basic/category/single.jhtml?id="+pid+"&vo.sort=NEWS&rnd="+Math.random();
	
	$.weeboxs.open(url, {
		title:'系统分类',
		contentType:'iframe', 
		width:800, height:400,
		onok:function(box){
	   	 	var name = "lstItems";
	   		box.find("iframe")[0].id   = name;
	   		box.find("iframe")[0].name = name;
	   		setTimeout(function(){
	   			var data = document.getElementById(name).contentWindow.getSelectCategory();
	   			if(data!=""){
	   				
	   				if(document.getElementById("parentCategoryId")!=null){
						document.getElementById("parentCategoryId").value=data.id;
					}
					
	   				if(document.getElementById("parentCategoryName")!=null){
						document.getElementById("parentCategoryName").value=data.name;
					}
	   			}else{
	   				alert("请选择所属分类");
					return;
	   			}
	   			
	   			box.close();
	   		}, 20);
		}
	});
}
</script>
</head>
<body>
<div class="main">
    <div class="subTitle">
        <h2><strong>文章管理</strong></h2>
    </div>
	<h3 class="subBoxTitle mT5"><c:if test="${empty id}">添&nbsp;&nbsp;&nbsp;&nbsp;加</c:if><c:if test="${not empty id}">修&nbsp;&nbsp;&nbsp;&nbsp;改</c:if></h3>
<form name="form1" action="<c:url value='/admin/basic/news/save.jhtml' />" method="post" onsubmit="return Validator.Validate(this,3);" enctype="multipart/form-data">
	<div class="ntable_mid mT10" >
        <table width="100%" class="nt_table">
            <tr>
                <td width="80" class="gray" height="40" align="right" ><font color="red">*</font>标题：</td>
                <td colspan="5"><input name="vo.title" type="text" class="ntext_01" value="${vo.title }" size="110" dataType="Require" msg="请输入标题" /></td>
			</tr>
			<tr>
                <td width="80" class="gray" height="40" align="right" ><font color="red">*</font>作者：</td>
                <td><input name="vo.author" type="text" class="ntext_01" value="${vo.author }" size="35" dataType="Require" msg="请输入作者" /></td>
                <td width="80" class="gray" height="40" align="right" ><font color="red">*</font>日期：</td>
                <td><input name="vo.ttime" type="text" class="ntext_01" value="${vo.ttime }" size="35" readonly="readonly" onclick="WdatePicker()"  dataType="Require" msg="请输入日期" /></td>
                <td class="gray" height="40" align="right" ><font color="red">*</font>类型：</td>
                <td>
                	<select name="vo.sort"  dataType="Require" msg="请选择类型">
                		<option value="" <c:if test="${empty vo.sort}">selected="selected"</c:if>>---请选择---</option>
	                	<c:forEach var="sort" items="${sorts}">
	                		<option value="${sort }" <c:if test="${vo.sort==sort}">selected="selected"</c:if>>${sort.text }</option>
	                	</c:forEach>
                	</select>
                </td>
            </tr>
			<tr>
                <td class="gray" height="40" align="right" ><font color="red">*</font>所属分类：</td>
                <td>
                	<input id="parentCategoryName" name="vo.category.name" type="text" class="ntext_01" value="${vo.category.name }" size="35" readonly="readonly" dataType="Require" msg="请输入分类" />
                	<input type="button" class="btn" value="选择" onclick="openSelectSingleCategory();"/>
                	<input id="parentCategoryId" name="vo.category.id" type="hidden" value="${vo.category.id }" />
                </td>
                <td class="gray" height="40" align="right" >图片：</td>
                <td colspan="3">
                <input name="uploadImage" type="file" />
                <c:if test="${not empty vo.path}">
                	<img alt="新闻图片" src="<c:url value='${vo.path }' />" width="30" height="30" />
                </c:if>
                </td>
            </tr>
			<tr>
                <td class="gray" height="40" align="right" >内容：</td>
                <td colspan="5">
                	<textarea id="content" name="vo.content" rows="9" cols="100">${vo.content }</textarea>
                	<script type="text/javascript">
					var _extraHeight=480;
					CKEDITOR.replace("content", {
						toolbar : 'Simple',
						height : 480,
						kt_image : {
							uploadURL : "<c:url value='/ckeditor-upload/descImage.jhtml'/>",
							fileName  : "descImage"
						}
					});
					</script>
                </td>
            </tr>
        </table>
    </div>
    
	<div class="nbot_control mT10">
		<input type="hidden" name="vo.id" value="${id}" />
        <input id="save" type="submit" class="formBtn01" value="保 存" />&nbsp;&nbsp;&nbsp;&nbsp;
		<input id="back" type="button" class="formBtn02" value="返 回"  onclick="location.href='<c:url value='/admin/basic/news/index.jhtml' />';" />
    </div>
</form>
</div>
</body>
</html>

